Repository navigation
[AISAGE-733] perf(gateway): combine provider metadata uploads - #9711
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe follow-up commit only relocates and renames event-local provider-metadata extraction in the three usage parsers; the logic is behavior-preserving and no new defects were found. Assumptions: Files Reviewed (3 files)
Previous Review Summaries (2 snapshots, latest commit 36d6967)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 36d6967)Status: No Issues Found | Recommendation: Merge Executive SummaryThe follow-up commit removes the redundant generation-ID tracking, flattens the archive key to Assumptions: Files Reviewed (10 files)
Previous review (commit 1287f8e)Status: No Issues Found | Recommendation: Merge Executive SummaryReviewed the combined provider-metadata archive change across the gateway, usage parsers, and R2 helpers; the new collector semantics, deferral/race behavior, and parser-selection change match the behavior they replace, and no high-confidence defects were found in the changed code. Assumptions: Files Reviewed (17 files)
Reviewed by deepseek-flash-latest · Input: 39.1K · Output: 4.2K · Cached: 444.4K Review guidance: REVIEW.md from base branch |
Summary
processUsageparsing pass rather thanrewriteModelResponse. The rewriter still strips provider metadata and rewrites client-visible usage. No new stream pass, inference-blocking upload, or database write is introduced.<usage_id>.jsonat the bucket root, containing version-1 routing fields and optionalvercel: { metadata }. Preserve the provider's generation ID inside its raw metadata rather than storing a redundant copy.api_request_logchanges.Verification
No manual UI, live-provider, or live-R2 testing. This is a server-side archive change; automated tests use local PostgreSQL and an in-memory R2 client.
Automated Checks
--detectOpenHandles: 275 tests across 6 suites passed and exited cleanly. The broader suite retains its existing open-handle warning from Sentry/rewriter test resources; that runner was stopped after all tests passed.pnpm --filter @kilocode/web-shared typecheck,pnpm --filter ai-gateway typecheck, andpnpm exec tsgo --noEmit -p apps/web/tsconfig.jsonpassed.pnpm format,oxfmt --check,oxlint, andgit diff --checkpassed.origin/main(fe50ac74d4) without rewriting published history.5a72089585; all seven review threads are resolved and no new issues were found.Visual Changes
N/A
Reviewer Notes
after()callback without starting I/O.countAndStoreUsagesynchronously attaches the Vercel raw-parsing completion promise. Serialization waits for parsing settlement or the first protocol terminal, not generation lookup, pricing, billing publication, or database persistence.application/json/text/event-streamselects the actual response parser, with requested streaming mode as fallback. JSON fallback usage is accounted rather than discarded, and the storedstreamedflag reflects the actual response format. Unterminated-SSE-event behavior is unchanged.[DONE]is a completion notification, not metadata extraction; the held-open-stream regression proves it releases capture before transport EOF while accounting still drains normally.Models Used
kilo/openai/gpt-6-luna, reasoninghigh, for archive/consumer research, mechanical rewriter/naming changes, and handler regression coverage.